﻿#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    void push(int value)
    {
        if (MixStack.size() == 0 || value <= MixStack.top())
        {
            MixStack.push(value);
        }
        BaseStack.push(value);
    }
    void pop()
    {
        if (BaseStack.top() == MixStack.top())
        {
            MixStack.pop();
        }
        BaseStack.pop();
    }
    int top()
    {
        return BaseStack.top();
    }
    int min()
    {
        return MixStack.top();
    }
private:
    stack<int> BaseStack;
    stack<int> MixStack;
};

/*
数据范围：操作数量满足0≤n≤300  ，输入的元素满足∣val∣≤10000
进阶：栈的各个操作的时间复杂度是O(1)  ，空间复杂度是O(n)

示例:
输入:    ["PSH-1","PSH2","MIN","TOP","POP","PSH1","TOP","MIN"]
输出:    -1,2,1,-1
解析:
"PSH-1"表示将-1压入栈中，栈中元素为-1
"PSH2"表示将2压入栈中，栈中元素为2，-1
“MIN”表示获取此时栈中最小元素==>返回-1
"TOP"表示获取栈顶元素==>返回2
"POP"表示弹出栈顶元素，弹出2，栈中元素为-1
"PSH1"表示将1压入栈中，栈中元素为1，-1
"TOP"表示获取栈顶元素==>返回1
“MIN”表示获取此时栈中最小元素==>返回-1

示例1
输入：
 ["PSH-1","PSH2","MIN","TOP","POP","PSH1","TOP","MIN"]

返回值：
-1,2,1,-1
*/

